<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <body>
        <ui:composition template="./../Template/generalTemplate.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel id="addEmployee" header="Add New Employee" style="height:495px;">
                        <div style="margin-left:350px;margin-top:30px;">
                            <h:panelGrid id="grid" columns="3">
                                <h:outputText value="UserName:"/>
                                <h:inputText required ="true" requiredMessage="User Name cannot be empty" value="#{addEmployeeManagedBean.employee.userName}"/>
                                <br/>
                                <h:outputText value="Name:"/>
                                <h:inputText required ="true" requiredMessage="Name cannot be empty" value="#{addEmployeeManagedBean.employee.name}"/>
                                <br/>
                               
                                <h:outputText value="DOB(DD-MM-YYYY):"/>
                                <p:inputMask required ="true" requiredMessage="DOB cannot be empty" value="#{addEmployeeManagedBean.employee.DOB}" mask="99-99-9999"/>
                                <br/>
                                <h:outputText value="Personal Email Address:"/>
                                <p:inputText required="true" value="#{addEmployeeManagedBean.employee.personalEmail}" requiredMessage="Personal email address is required for emloyee's initial password receiving"/>
                                <br/>
                                <h:outputText value="ContactNumber:"/>
                                <p:inputMask required ="true" requiredMessage="Contact Number cannot be empty" value="#{addEmployeeManagedBean.employee.contactNumber}" mask="(99)99999999"/>
                                <br/>
                               
                              
                                </h:panelGrid>
                              <br/>
                                <h:outputText value="Department:" style="margin-right: 80px;"/>
                                <h:selectOneMenu id="companyId"  onchange="this.form.submit()" immediate="true" value="#{addEmployeeManagedBean.employee.department}" required="true" requiredMessage="Department Cannot be Blank" style="width:170px;">
                                    <f:selectItem itemLabel="Admin" itemValue="Admin" />
                                    <f:selectItem itemLabel="Sales" itemValue="Sales" />
                                </h:selectOneMenu>
                              
                               <br/>
                                <br/>
                                <h:outputText value="Roles " style="margin-right: 115px;"/>
                                
                                <h:selectManyMenu value="#{addEmployeeManagedBean.selectedRoles}" style="height:100px;width:170px;" >  
                                    <f:selectItems value="#{addEmployeeManagedBean.roleManager.allRoles}"  
                                                   var="allRoles" itemLabel="#{allRoles.roleName}" 
                                                   itemValue="#{allRoles.id}" />  
                                </h:selectManyMenu>
                                <br/>
                               <br/>
                                <h:outputText value="Salesman Level:" rendered="#{addEmployeeManagedBean.isSales()}" style="margin-right: 55px;"/>
                                <h:selectOneMenu value="#{addEmployeeManagedBean.salesman.salesManLevel}" style="width:170px;" rendered="#{addEmployeeManagedBean.isSales()}">
                                    <f:selectItem itemLabel="Basic Salesman" itemValue="1" />
                                    <f:selectItem itemLabel="Senior Salesman" itemValue="2" />
                                    <f:selectItem itemLabel="Sales Executive" itemValue="3" />
                                    <f:selectItem itemLabel="Sales Manager" itemValue="4" />
                                </h:selectOneMenu>
                                <br/>
                                
                         
                            <p:commandButton value="Save" ajax="true" update="statusMessages addEmployee" actionListener="#{addEmployeeManagedBean.saveNewEmployee}"/>
                            <p:commandButton value="Add More Employees"    actionListener="#{addEmployeeManagedBean.oneMore}" rendered="#{addEmployeeManagedBean.show}"/>
                        </div>
                    </p:panel>
                </h:form>
            </ui:define>

            <ui:define name="bottom">
                <p:messages id ="statusMessages"/>
            </ui:define>

        </ui:composition>
    </body>

</html>
